import openpyxl

wb = openpyxl.load_workbook("/Users/zhangxiangbin/Sync/02 招商金科/工时统计/2023年/2023年11月人力投入工时_外勤_预表.xlsx")

# ws = wb['2023年11月人力投入工时_外勤_预表']
ws = wb.active

# print(ws.title)

# 全表遍历方法1
# for row in ws.values:
#     for value in row:
#         print(value)

# 全表遍历方法2
# for row in ws:
#     for cell in row:
#         print(cell.value)
#     print("----------")

# print(ws.max_row)
# print(ws.max_column)

# 全表遍历方法3
# for x in range(1, ws.max_row+1):
#     for y in range(1,ws.max_column+1):
#         cell = ws.cell(row=x, column=y)
#         if cell is not None:
#             print(cell.value)

# 列遍历方法1
# for cell in list(ws.columns)[0]:
#     print(cell.value)

# 列遍历方法2
# for col in ws.columns:
#     for cell in col:
#         print(cell.value)

# 行遍历方法1
# for cell in list(ws.rows)[5]:
#     print(cell.value)

# 行遍历方法2
# for row in ws.rows:
#     for cell in row:
#         print(cell.value)

# 获取cell的行列信息
for cell in list(ws.rows)[6]:
    print(cell.col_idx)
    print(cell.column_letter)
    print(cell.row)
    print(cell.coordinate)
